﻿package mortal.game.view.copy.sixBoss.view
{
    import Message.DB.Tables.*;
    import Message.Public.*;
    import com.mui.controls.*;
    import com.mui.display.*;
    import extend.language.*;
    import fl.data.*;
    import flash.display.*;
    import flash.events.*;
    import mortal.common.global.*;
    import mortal.component.window.*;
    import mortal.game.events.*;
    import mortal.game.manager.*;
    import mortal.game.mvc.*;
    import mortal.game.resource.*;
    import mortal.game.resource.tableConfig.*;
    import mortal.game.view.common.*;
    import mortal.game.view.copy.sixBoss.data.*;
    import mortal.game.view.copy.sixBoss.renderer.*;
    import mortal.game.view.copy.sixBoss.utils.*;
    import mortal.mvc.core.*;
    import mortal.mvc.interfaces.*;

    public class SixBossKillRewardWin extends SmallWindow
    {
        private var _bossTitle:GTextFiled;
        private var _rewardBg1:ScaleBitmap;
        private var _rewardBg2:ScaleBitmap;
        private var _rewardBg3:ScaleBitmap;
        private var _rankInfo1:GTextFiled;
        private var _rankInfo2:GTextFiled;
        private var _rankInfo3:GTextFiled;
        private var _rankReward:GTileList;
        private var _normalReward:GTileList;
        private var _lastKillReward:GTileList;
        private var _splitLine1:ScaleBitmap;
        private var _splitLine2:ScaleBitmap;
        private var _splitLine3:ScaleBitmap;
        private var _takeBtn:GLoadingButton;
        private static var _instance:SixBossKillRewardWin;

        public function SixBossKillRewardWin(param1:ILayer = null)
        {
            super(param1);
            setSize(256 - 11, 317 + 95);
            this.layer = LayerManager.windowLayer;
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            this._bossTitle = UIFactory.gTextField("", 0, 11 - 4, 256, 25, this, GlobalStyle.textFormatHuang2.setSize(14).center());
            this._rewardBg1 = UIFactory.bg(18, 33, 220, 100 + 10, this, ImagesConst.RewardBg2);
            this._rewardBg2 = UIFactory.bg(18, 33 + 116, 220, 100 + 10, this, ImagesConst.RewardBg2);
            this._rewardBg3 = UIFactory.bg(18, 33 + 116 * 2, 220, 100 + 10, this, ImagesConst.RewardBg2);
            this._rankInfo1 = UIFactory.gTextField("", 0, 44, 256, 25, this, GlobalStyle.textFormatHuang.setSize(14).center());
            this._rankInfo2 = UIFactory.gTextField("", 0, 44 + 116, 256, 25, this, GlobalStyle.textFormatHuang.setSize(14).center());
            this._rankInfo3 = UIFactory.gTextField("", 0, 44 + 116 * 2, 256, 25, this, GlobalStyle.textFormatHuang.setSize(14).center());
            this._rankReward = UIFactory.tileList(13, 71, 275, 60 + 4, this);
            this._rankReward.columnWidth = 60;
            this._rankReward.rowHeight = 60;
            this._rankReward.horizontalGap = 0;
            this._rankReward.verticalGap = 0;
            this._rankReward.setStyle("skin", new Bitmap());
            this._rankReward.setStyle("cellRenderer", SixBossRewardCellRenderer);
            this._splitLine1 = UIFactory.bg(23, 65, 213, 2, this, ImagesConst.SplitLine);
            this._normalReward = UIFactory.tileList(13, 71 + 116, 275, 64, this);
            this._normalReward.columnWidth = 60;
            this._normalReward.rowHeight = 60;
            this._normalReward.horizontalGap = 0;
            this._normalReward.verticalGap = 0;
            this._normalReward.setStyle("skin", new Bitmap());
            this._normalReward.setStyle("cellRenderer", SixBossRewardCellRenderer);
            this._splitLine2 = UIFactory.bg(23, 65 + 116, 213, 2, this, ImagesConst.SplitLine);
            this._lastKillReward = UIFactory.tileList(13, 71 + 116 * 2, 275, 64, this);
            this._lastKillReward.columnWidth = 60;
            this._lastKillReward.rowHeight = 60;
            this._lastKillReward.horizontalGap = 0;
            this._lastKillReward.verticalGap = 0;
            this._lastKillReward.setStyle("skin", new Bitmap());
            this._lastKillReward.setStyle("cellRenderer", SixBossRewardCellRenderer);
            this._splitLine3 = UIFactory.bg(23, 65 + 116 * 2, 213, 2, this, ImagesConst.SplitLine);
            this._takeBtn = UIFactory.gLoadingButton(ResFileConst.ConfirmSmallBtn, 136 + 4 - 65, 311 - 65 + 138, 110, 33, this);
            this._takeBtn.configEventListener(MouseEvent.CLICK, this.onClickHandler);
            return;
        }// end function

        override protected function configParams() : void
        {
            super.configParams();
            paddingBottom = 40 - 12 + 11;
            return;
        }// end function

        private function setItemListPos() : void
        {
            this._rankReward.x = (this.width - this._rankReward.columnWidth * this._rankReward.length) / 2;
            this._normalReward.x = (this.width - this._normalReward.columnWidth * this._normalReward.length) / 2;
            this._lastKillReward.x = (this.width - this._lastKillReward.columnWidth * this._lastKillReward.length) / 2;
            return;
        }// end function

        public function set data(param1:SMonsterSiegeResultMsg) : void
        {
            var _loc_8:DataProvider = null;
            var _loc_2:* = BossConfig.instance.getInfoByCode(param1.bossCode);
            this._bossTitle.text = Language.getStringByParam(40935, _loc_2.name);
            this._rankInfo1.text = Language.getStringByParam(40936, param1.rank);
            this._rankInfo2.text = Language.getString(40937);
            if (param1.iskiller)
            {
                this._rankInfo3.text = Language.getString(40938);
                setSize(256 - 11, 317 + 95);
                this._takeBtn.y = 311 - 65 + 138;
                this._splitLine3.visible = true;
                this._rewardBg3.visible = true;
            }
            else
            {
                this._rankInfo3.text = "";
                setSize(256 - 11, 317 + 95 - 116);
                this._takeBtn.y = 311 - 65 + 138 - 116;
                this._splitLine3.visible = false;
                this._rewardBg3.visible = false;
            }
            var _loc_3:* = SixBossUtil.getRankRewardByRank(param1.bossCode, param1.rank);
            var _loc_4:* = SixBossUtil.getRankRewardByRank(param1.bossCode, -1);
            var _loc_5:* = SixBossUtil.getRankRewardByRank(param1.bossCode, 0);
            var _loc_6:* = new DataProvider();
            _loc_6.addItem(_loc_3);
            this._rankReward.dataProvider = _loc_6;
            this._rankReward.drawNow();
            var _loc_7:* = new DataProvider();
            _loc_7.addItem(_loc_4);
            this._normalReward.dataProvider = _loc_7;
            this._normalReward.drawNow();
            if (param1.iskiller)
            {
                _loc_8 = new DataProvider();
                _loc_8.addItem(_loc_5);
                this._lastKillReward.dataProvider = _loc_8;
                this._lastKillReward.drawNow();
            }
            this.setItemListPos();
            return;
        }// end function

        private function onClickHandler(event:MouseEvent) : void
        {
            Dispatcher.dispatchEvent(new DataEvent(EventName.SixBossGetReward));
            this.hide();
            return;
        }// end function

        override protected function disposeImpl(param1:Boolean = true) : void
        {
            super.disposeImpl();
            this._rankInfo1.dispose();
            this._rankInfo1 = null;
            this._rankInfo2.dispose();
            this._rankInfo2 = null;
            this._rankInfo3.dispose();
            this._rankInfo3 = null;
            this._rankReward.dispose();
            this._rankReward = null;
            this._normalReward.dispose();
            this._normalReward = null;
            this._lastKillReward.dispose();
            this._lastKillReward = null;
            this._splitLine1.dispose();
            this._splitLine1 = null;
            this._splitLine2.dispose();
            this._splitLine2 = null;
            this._splitLine3.dispose();
            this._splitLine3 = null;
            this._takeBtn.dispose();
            this._takeBtn = null;
            this._bossTitle.dispose();
            this._bossTitle = null;
            this._rewardBg1.dispose();
            this._rewardBg1 = null;
            this._rewardBg2.dispose();
            this._rewardBg2 = null;
            this._rewardBg3.dispose();
            this._rewardBg3 = null;
            return;
        }// end function

        public static function get instance() : SixBossKillRewardWin
        {
            if (_instance == null)
            {
                _instance = new SixBossKillRewardWin;
            }
            return _instance;
        }// end function

    }
}
